package com.charity.rest.controller.manage.website;

import java.util.List;
import com.charity.website.service.IWebCategoryService;
import com.charity.website.vo.model.WebCategoryModel;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 网站类目  前端控制器
 *
 */
@RestController
@RequestMapping("/manage/manageCategory")
@AllArgsConstructor
public class ManageCategoryController {

    private final IWebCategoryService webCategoryService;

    @PostMapping("/getTreeList")
    public List<WebCategoryModel> getTreeList(@RequestBody WebCategoryModel model) {
        return webCategoryService.getTreeList(model);
    }

    @PostMapping("/getCategoryList")
    public List<WebCategoryModel> getCategoryList(@RequestBody WebCategoryModel query) {
        return webCategoryService.getCategoryList(query);
    }

    @GetMapping(value = "/{id}")
    public WebCategoryModel getWebCategoryById(@PathVariable("id") Long id) {
        return webCategoryService.getWebCategoryById(id);
    }

    @PostMapping("/createWebCategory")
    public Long createWebCategory(@RequestBody WebCategoryModel model) {
        return webCategoryService.createWebCategory(model);
    }

    @PostMapping("/updateWebCategory")
    public void updateWebCategory(@RequestBody WebCategoryModel model) {
        webCategoryService.updateWebCategory(model);
    }

    @DeleteMapping("/{id}")
    public Integer deleteWebCategory(@PathVariable("id") Long id) {
        return webCategoryService.deleteWebCategory(id);
    }
}
